﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Configuration;
using System.Data;

public partial class _Default : System.Web.UI.Page
{

    string getTheSlotNumber;
   
    protected void Page_Load(object sender, EventArgs e)
    {
        Button3.Style.Add("background-color", "#FFC643");
        Button4.Style.Add("background-color", "#FFC643");

        getTheSlotNumber = Request.QueryString["soltnumber"];
        Label1.Text = getTheSlotNumber;

        Image2.ImageUrl = "mapImageHandler.ashx?myMapID=" + getTheSlotNumber;

    }


    protected void Button4_Click(object sender, EventArgs e)
    {
        Response.Redirect("Selectslots.aspx");
    }


    protected void Button3_Click(object sender, System.EventArgs e)
    {

        DateTime d1 = (DateTime)Session["mySesD"];
        TimeSpan t1 = (TimeSpan)Session["mySes1"];
        TimeSpan t2 = (TimeSpan)Session["mySes2"];

        

        String ConString = ConfigurationManager.ConnectionStrings["myDBConnection"].ConnectionString;
        using (SqlConnection connection = new SqlConnection(ConString))
        {            
            connection.Open();
            SqlCommand command = new SqlCommand("bookingDateTime", connection);
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@myT1", t1);
            command.Parameters.AddWithValue("@myT2", t2);
            command.Parameters.AddWithValue("@myD1", d1);
            command.Parameters.AddWithValue("@mySlot", getTheSlotNumber);           
            command.ExecuteNonQuery();
            connection.Close();

            connection.Open();
            SqlCommand cmd2 = new SqlCommand("compareAvailability", connection);
            cmd2.CommandType = System.Data.CommandType.StoredProcedure;
            cmd2.ExecuteNonQuery();
            connection.Close();       

        }

    }
}